Skip to content

drivers: ethernet: vsc8541: various fixes #91726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

robhancocksed
Copy link
Contributor

  • Added missing MDIO enable/disable calls around accessing PHY registers, to make sure the MDIO bus is active first
  • Cleaned up internal functions to use uint16_t for PHY register values
  • Fixed inverted reset GPIO line
  • Added SW reset timeout
  • Implemented cfg_link function required by some MAC drivers

@robhancocksed
Copy link
Contributor Author

It looks like the arch.interrupt.gen_isr_table_local.riscv test is failing on the ganymed_bob and ganymed_sk boards where I modified the .dts files. However, those build errors also seem to happen on the main branch, so they seem unrelated to these changes?

@@ -30,7 +30,7 @@
reg = <0x0>;
status = "okay";

reset-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a entry in the migration guide, stating that this got fixed, so users with custom boards know that they have to change it too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

*/
static int phy_mc_vsc8541_cfg_link(const struct device *dev, enum phy_link_speed speeds)
static int phy_mc_vsc8541_cfg_link(const struct device *dev, enum phy_link_speed adv_speeds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe wait until #91354 is merged, it will provide phy_mii_cfg_link_autoneg() to set the autoneg registers according to the ethernet specs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check out #91572 62e692e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased on top of those changes - we can now make use of some of the common phy_mii code here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to cherry-pick b58b241 from #91572
and putting it before your changes

I fixed there some other things I noticed

if (count++ > 1000) {
LOG_ERR("phy reset timed out");
return -ETIMEDOUT;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/* we use limited advertising, to force gigabit speed */
	/* initial version of this driver supports only 1GB/s */
	/* 1000MBit/s + AUTO */
	ret = phy_mc_vsc8541_write(dev, PHY_REG_PAGE0_ADV, (1 << 8) | (1 << 6) | 0x01);
	if (ret) {
		return ret;
	}
	ret = phy_mc_vsc8541_write(dev, PHY_REG_PAGE0_CTRL1000, (1 << 12) | (1 << 11) | (1 << 9));
	if (ret) {
		return ret;
	}
	/* start auto negotiation */
	ret = phy_mc_vsc8541_write(dev, PHY_REG_PAGE0_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
	if (ret) {
		return ret;
}

this can probably be removed, autoneg is enabled by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@github-actions github-actions bot added the Release Notes To be mentioned in the release notes label Jun 17, 2025
if (ret) {
return ret;
}

/* start auto negotiation */
ret = phy_mc_vsc8541_write(dev, PHY_REG_PAGE0_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this linke is also no longer needed, as we don't change the autoneg regs on startup, so we don't need to restart it, autoneg is btw enabled by default

Comment on lines 394 to 400
/**
* @brief Reconfigure the link speed
*
* @param dev device structure to phy
* @param adv_speeds speeds to be advertised
* @param flags configuration flags
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these kind of descriptions for doxygen are only needed for public apis in their headers, not in the source files

*/
static int phy_mc_vsc8541_cfg_link(const struct device *dev, enum phy_link_speed speeds)
static int phy_mc_vsc8541_cfg_link(const struct device *dev, enum phy_link_speed adv_speeds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to cherry-pick b58b241 from #91572
and putting it before your changes

I fixed there some other things I noticed

@robhancocksed
Copy link
Contributor Author

@maass-hamburg I cherry-picked in the commit you mentioned, as well as one other with a mutex change, from your branch and rebased my changes on top of it. I think I have addressed your other comments as well.

@robhancocksed
Copy link
Contributor Author

As noted before, those ganymed_bob and ganymed_sk test failures are not new, they also are occurring on weekly builds on the main branch.

maass-hamburg
maass-hamburg previously approved these changes Jun 18, 2025
maass-hamburg and others added 7 commits June 19, 2025 15:54
- implement configure link
- support half duplex
- use defines from mii.h
- fix check ret vals

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
use mutex to protect page register

phy_mc_vsc8541_get_link got removed from
phy_mc_vsc8541_link_cb_set so, that
phy_mc_vsc8541_link_monitor (own thread)
is the only one to change data->state

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Fixed some build warnings in the driver from previous changes by
removing an unused variable and hooking up the cfg_link function. Also
removes some implicit boolean conversions.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
The driver was not enabling the MDIO bus before trying to access
registers. Added enabling and disabling the bus around PHY register
accesses.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
The internal register read/write functions used uint32_t for the values
even though the registers are only 16 bits wide, resulting in a bunch of
casting. Change the internal functions to use uint16_t and wrap them for
the external read/write API which uses uint32_t.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
For GPIOs driving active-low signals, such as the VSC8541's reset pin,
they are supposed to be declared as active low in the device tree, and
set to 1 to assert and 0 to clear. Change the driver as such so that it
does not leave the PHY stuck in reset when so configured.

Also changed all in-tree board DTS files for this PHY to properly
declare the reset GPIO as active low.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Mention a change to the reset-gpios handling in the vsc8541 PHY driver.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
The driver previously could enter an infinite loop if the PHY software
reset failed to complete, which could happen due to hardware reset
issues or MDIO bus problems. Add a timeout of 1000 iterations so we
report an error in this scenario rather than causing a lockup.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Add support for disabling autonegotiation to the cfg_link callback, as
with the phy_mii driver.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
@maass-hamburg
Copy link
Collaborator

@robhancocksed please rebase to current main, hopefully the unrelated CI fails had been fixed, if not please open an issue

@kartben kartben closed this Jun 25, 2025
@kartben kartben reopened this Jun 25, 2025
Copy link

@maass-hamburg
Copy link
Collaborator

needs #92194 to be fixed

@robhancocksed
Copy link
Contributor Author

@robhancocksed please rebase to current main, hopefully the unrelated CI fails had been fixed, if not please open an issue

As you noted, the test failures on ganymed_bob are also occurring on the main branch, so rebasing will not help at this point. I assume this PR is flagging those failures since it touched the .dts files for those boards. So either this can be merged despite the test failures, or #92194 will need to be fixed.

@maass-hamburg
Copy link
Collaborator

@robhancocksed please rebase to current main, hopefully the unrelated CI fails had been fixed, if not please open an issue

As you noted, the test failures on ganymed_bob are also occurring on the main branch, so rebasing will not help at this point. I assume this PR is flagging those failures since it touched the .dts files for those boards. So either this can be merged despite the test failures, or #92194 will need to be fixed.

correct, probably needs a fix like #91391 but for your effected boards

@dkalowsk
Copy link
Collaborator

@robhancocksed RC1 has been tagged, which means all new PRs need to be bug fixes with an attached GitHub issue. Given that this PR is all bug fixes, can you create an issue and attach it to this PR so we can merge for RC2?

@robhancocksed
Copy link
Contributor Author

@dkalowsk I created an issue entry to track the problems being fixed here: #92553

@maass-hamburg maass-hamburg linked an issue Jul 2, 2025 that may be closed by this pull request
1 task
@dkalowsk dkalowsk added this to the v4.2.0 milestone Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Ethernet platform: sensry Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vsc8541 Ethernet PHY driver issues
5 participants